package com.llxz.blog.article.repository;

import com.llxz.blog.article.entity.Article;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.stereotype.Component;

import java.util.List;

@Document(collection = "article")

public interface ArticleRepository extends MongoRepository<Article, String> {
    /**
     *
     * @param articleId
     * @return
     */
    Article findByArticleId(String articleId);

    /**
     *
     * @param articleId
     */
    void removeByArticleId(String articleId);

    /**
     *
     * @param flag
     * @return
     */
    List<Article> findAllByFlag(Integer flag);

    /**
     *
     * @param phone
     * @return
     */
    List<Article> findAllByPhone(String phone);

    /**
     * 移除某用户的文章
     * @param phone
     */
    int removeByPhone(String phone);

    /**
     * 按分类查询
     * @param classtwoId
     * @return
     */
    List<Article> findAllByClasstwoId(String classtwoId);
    /**
     * 按一级分类
     * @param classId
     * @return
     */
    List<Article> findAllByClassIdAndFlag(String classId, Integer flag);

    /**
     *按二级分类
     * @param
     * @param flag
     * @return
     */
    List<Article> findAllByClasstwoIdAndFlag(String classtwoId, Integer flag);

}
